/* tslint:disable:no-console */

import {InterfaceUser} from '@/interface/InterfaceUser';
import {InterfaceBankCard as bankCardType} from '@/interface/InterfaceBankCard';
import {ActionContext, ActionTree, Commit, Dispatch, GetterTree, MutationTree} from 'vuex';
import * as types from '../mutation-types';


import '@/interface/InterfaceType';

export default class UserStore {

    public static initState: InterfaceUser = {
        token: '',
        wechatCode: '',
        addressId: 0,
        age: 0,
        authentication: 0,
        avatar: null,
        avatarId: 0,
        belief: 0,
        birthday: 0,
        bloodtype: 0,
        carPurchase: 0,
        chatStatus: 1,
        child: 0,
        cityId: 0,
        code: '',
        companyIndustry: 0,
        companyNature: 0,
        companyPosition: '',
        constellation: 0,
        consultationNum: 0,
        cookingCondition: 0,
        countryId: 0,
        dailylife: 0,
        datingStyle: 0,
        directCount: 0,
        distributMoney: '0.00',
        districtId: 0,
        divisionOfLabour: 0,
        drink: 0,
        duties: 0,
        education: 0,
        evaluation: 0,
        familyRanking: 0,
        fatherWork: 0,
        gender: 0,
        height: 0,
        hobby: '',
        hometownCityId: 0,
        hometownProvinceId: 0,
        housePurchase: 0,
        identityIntroduction: '',
        income: 0,
        industry: '',
        infodegree: 0,
        introduction: '',
        introductionTime: 0,
        isDelete: 0,
        livingWithParents: 0,
        major: 0,
        maritalStatus: 0,
        marriageTime: 0,
        masterLanguage: '',
        mateSelection: {
            age: '',
            child: 0,
            cityId: 0,
            education: '',
            height: '',
            housePurchase: 0,
            income: '',
            maritalStatus: 0,
            provinceId: 0,
            province: '',
            snapAge: '未填写',
            snapChild: '未填写',
            snapCityId: '未填写',
            snapEducation: '未填写',
            snapHeight: '未填写',
            snapHousePurchase: '未填写',
            snapIncome: '未填写',
            snapMaritalStatus: '未填写',
            snapProvinceId: '未填写',
            userId: 19,
        },
        money: '0.00',
        motherWork: 0,
        nation: 0,
        nickname: '',
        otherSideValues: 0,
        parentEconomy: 0,
        parentSituation: 0,
        parentalInsurance: 0,
        payPoints: '0',
        phone: '',
        photo: [],
        pid: 0,
        provinceId: 0,
        rank: null,
        rankName: '',
        registeredResidenceCityId: 0,
        registeredResidenceProvinceId: 0,
        share: 0,
        smoke: 0,
        snapBelief: '未填写',
        snapBloodtype: '未填写',
        snapCarPurchase: '未填写',
        snapChild: '未填写',
        snapCityId: '未填写',
        snapCompanyIndustry: '未填写',
        snapCompanyNature: '未填写',
        snapConstellation: '未填写',
        snapCookingCondition: '未填写',
        snapCountryId: '未填写',
        snapDailylife: '未填写',
        snapDatingStyle: '未填写',
        snapDistrictId: '未填写',
        snapDivisionOfLabour: '未填写',
        snapDrink: '未填写',
        snapDuties: '未填写',
        snapEducation: '未填写',
        snapEvaluation: '未填写',
        snapFamilyRanking: '未填写',
        snapFatherWork: '未填写',
        snapHeight: '未填写',
        snapHobby: '未填写',
        snapHometownCityId: '未填写',
        snapHometownProvinceId: '未填写',
        snapHousePurchase: '未填写',
        snapIncome: '未填写',
        snapIndustry: '未填写',
        snapLivingWithParents: '未填写',
        snapMajor: '未填写',
        snapMaritalStatus: '未填写',
        snapMarriageTime: '未填写',
        snapMasterLanguage: '未填写',
        snapMotherWork: '未填写',
        snapNation: '未填写',
        snapOtherSideValues: '未填写',
        snapParentEconomy: '未填写',
        snapParentSituation: '未填写',
        snapParentalInsurance: '未填写',
        snapProvinceId: '未填写',
        snapRegisteredResidenceCityId: '未填写',
        snapRegisteredResidenceProvinceId: '未填写',
        snapShare: '未填写',
        snapSmoke: '未填写',
        snapUniversity: '未填写',
        snapWantChildren: '未填写',
        snapWeddingForm: '未填写',
        snapWeight: '未填写',
        snapWorkingCondition: '未填写',
        snapZodiac: '未填写',
        supplier: null,
        teamCount: 0,
        type: 1,
        university: 0,
        userId: 0,
        userNo: '',
        userRank: 1,
        validityTime: 0,
        wantChildren: 0,
        weddingForm: 0,
        weight: 0,
        workingCondition: 0,
        zodiac: 0,
    };
    public static state: InterfaceUser = UserStore.initState;


    public static mutations: MutationTree<InterfaceUser> = {
        [types.USER_UPDATE](state: InterfaceUser, user: InterfaceUser) {
            state = Object.assign(state, user);
            let infodegree = Math.round(state.infodegree * 100);
            infodegree = infodegree > 100 ? 100 : infodegree;
            if (state.avatarId === 0) {
                state = Object.assign(state, {
                    avatar: {
                        extension: 'jpg',
                        fileName: 'user-no-face.jpg',
                        filePath: require('@/assets/images/user-no-face.jpg'),
                        fileSize: 6103,
                        fileStatus: {id: 0, userId: state.userId, fileId: 0, content: '', type: 1, status: 1},
                        fileType: 'image',
                        fileUrl: 'localhost',
                        groupId: 2,
                        id: 0,
                        isDelete: 0,
                        isUser: 1,
                        storage: 'localhost',
                    },
                });
            }
            state = Object.assign(state, {infodegree});
        },
        [types.USER_EXIT](state: InterfaceUser) {
            state = Object.assign(state, UserStore.initState);
        },
    };


    public static action: any = {};
}
